﻿using System;
using System.Collections.Generic;
using MySql.Data.MySqlClient;

namespace UDPSocketProject
{
    public class PhoneDataManager
    {
        public static void InsertDataFrame(int routerId,List<DataFrameModel> dataFrameList)
        {
            foreach (DataFrameModel dataFrameModel in dataFrameList)
            {
                if (dataFrameModel.stamac.Length < 1)
                {
                    Console.WriteLine("无效Mac地址，放弃保存数据。");
                    continue;
                }
                SqlHelper sqlHelper = new SqlHelper();
                string proceSQL = "CALL SavePhone(" + routerId + ",'" + dataFrameModel.stamac + "','" + dataFrameModel.apmac + "','" + dataFrameModel.ssid + "'," + dataFrameModel.rssi + "," + dataFrameModel.channel + ");";
                if (sqlHelper.execStoredProcedure(proceSQL))
                { 
                    Console.WriteLine(" √ 保存手机信息成功，手机Mac地址：{0} 采集设备Mac地址：{1}", dataFrameModel.stamac,dataFrameModel.apmac);
                }
                else
                {
                    Console.WriteLine(" X 保存手机信息失败，手机Mac地址：{0} 采集设备Mac地址：{1}",dataFrameModel.stamac,dataFrameModel.apmac);
                }
            }
        }
    }
}
